﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WPFSLVstoDesigner.Base;
using System.Drawing;
using System.Windows.Media;
using Microsoft.Office.Core;
using System.Windows.Media.Effects;
using vmlModel.Entities;
using System.ComponentModel;
using WPFSLVstoDesigner.XAMLFactory;

namespace WPFSLVstoDesigner.AutoShapes
{
    /// <summary>
    /// Interaction logic for ShapeRectangle.xaml
    /// </summary>
    public partial class ShapeRectangle : UserControl
    {
        #region "AutoShape Attributes"
        public vmlRect srcRec { get; set; }
        public vmlRoundrect srcRoundrect { get; set; }
        #endregion
        public ShapeRectangle()
        {
            InitializeComponent();
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            Canvas.SetTop(this, srcRec.MarginTop);
            Canvas.SetLeft(this, srcRec.MarginLeft);
            Canvas.SetZIndex(this, srcRec.Zindex);
            MainShape.Width = srcRec.Width;
            MainShape.Height = srcRec.Height;


            MainShape.Fill = new SolidColorBrush(srcRec.FillColor);
            MainShape.Stroke = new SolidColorBrush(srcRec.StrokeColor);
            MainShape.StrokeThickness = srcRec.StrokeWeight;
            if (srcRec.Stroke != null)
            {
                if (srcRec.Stroke.LiveAtrrs.Contains("weight")) MainShape.StrokeThickness = srcRec.Stroke.Weight;
                if (srcRec.Stroke.LiveAtrrs.Contains("color")) MainShape.Stroke = new SolidColorBrush(srcRec.Stroke.Color);
                MainShape.StrokeDashArray = srcRec.Stroke.vmlDashStyle;
                MainShape.Stroke.Opacity = srcRec.Stroke.Opacity;
                MainShape.StrokeLineJoin = srcRec.Stroke.vmlJoinStyle;
                MainShape.Stroke = new StrokeLineStyleBuilder().vmlRecLineStyle(srcRec);
            }
            if (srcRec.Fill != null)
            {
               MainShape.Fill = new FillBuilder().CreatevmlFill(srcRec); ;
            }

            //MainShape.CornerRadius = new CornerRadius(ShapeCornerRadius);
            ////Shadow
            //DropShadowBitmapEffect dps = new DropShadowBitmapEffect();
            //dps.SetValue(NameProperty, "dps");
            //dps.Softness = 0.1;
            //dps.Noise = 0;
            //dps.Opacity = 0.5;
            //dps.ShadowDepth = 11;
            //dps.Direction = 135;
            //dps.Color = System.Windows.Media.Color.FromRgb(byte.Parse(ShadowForeColorR.ToString()), byte.Parse(ShadowForeColorG.ToString()), byte.Parse(ShadowForeColorB.ToString())); 
            //MainShape.BitmapEffect = dps;

        }

    }
}
